<template>
  <div
    class="monitor"
    :class="['menu-expanded', expanded ? 'bgc-action2' : 'bgc-action1']"
  >
    <div
      class="monitor-menuList"
      v-show="expanded"
      v-for="(item, i) in items"
      :key="i"
    >
      {{ item.name }}
    </div>
    <div
      class="monitor-menu"
      @click="toggleMenu"
      :class="['menu-expanded', expanded ? 'bgc-action' : 'bgc-noAction']"
    >
      <div class="monitor-menu-menuBox">
        <div>{{ title }}</div>
        <div
          class="monitor-menu-menuBox-vator"
          :class="{ 'rotate-vator': expanded }"
        ></div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, defineProps, defineEmits } from "vue";
const props = defineProps(["title", "expanded", "items"]);
const emits = defineEmits(["toggle"]);

const toggleMenu = () => {
  emits("toggle");
};

const menuClass = [
  "menu-expanded",
  props.expanded ? "bgc-action2" : "bgc-action1",
];
</script>
<style lang="scss" scoped>
.monitor {
  width: 133px;
  height: auto;
  color: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  &-menuList {
    width: 113px;
    height: 31px;
    font-size: 16px;
    font-family: Alibaba PuHuiTi 2-55 Regular, Alibaba PuHuiTi 20;
    font-weight: normal;
    color: #ffffff;
    text-align: center;
    line-height: 31px;
    background-image: url("../assets/images/home/bgc_acquiesce.png");
    background-size: 100% 100%;
    margin: 12px 0 12px 0;
    cursor: pointer;
  }
  &-menu {
    width: 132.5px;
    height: 40px !important;
    position: relative;
    display: flex;
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
    font-size: 16px;
    font-family: Alibaba PuHuiTi 2-65 Medium, Alibaba PuHuiTi 20;
    font-weight: normal;
    color: #ffffff;
    background-image: url("../assets/images/home/bgc_noAction.png");
    background-size: 100% 100%;
    cursor: pointer;
    &-menuBox {
      width: 76px;
      height: 22px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      &-vator {
        width: 5px;
        height: 7px;
        transform: rotate(360deg); /* 旋转90度 */
        transition: transform 0.3s ease; /* 添加过渡效果 */
        background-image: url("../assets/images/home/icon_vator1.png");
        background-size: 100% 100%;
      }
    }
  }
}

.rotate-vator {
  transform: rotate(270deg); /* 旋转90度 */
  transition: transform 0.3s ease; /* 添加过渡效果 */
}
.bgc-action {
  background-image: url("../assets/images/home/bgc_action.png");
}

.bgc-noAction {
  background-image: url("../assets/images/home/bgc_noAction.png");
}

.bgc-action1 {
  background: none;
}
.bgc-action2 {
  background: linear-gradient(180deg, rgba(38, 57, 63, 0) 0%, #1a222c 100%);
}
.monitor-menuList:hover {
  background-image: url("../assets/images/home/bgc_hover.png");
}
.inspection-menuList:hover {
  background-image: url("../assets/images/home/bgc_hover.png");
}
</style>
